package com.xuetang9.t9.hotel.mapper.condition.impl;


import com.xuetang9.t9.hotel.utils.OverallConstant;

/**
 * 查询条件(分页查询)
 */
public class PageCondition {
    private Integer currPage;
    private Integer pageSize;

    public PageCondition() {
        this.currPage = 0;
        this.pageSize = OverallConstant.DEFAULT_PAGESIZE;
    }

    public PageCondition(Integer currPage, Integer pageSize) {
        this.currPage = currPage;
        this.pageSize = pageSize;
    }

    public boolean judge(){
        if(this.currPage == null && this.pageSize == null){
            return false;
        }
        return true;
    }

    public Integer getCurrPage() {
        if(currPage == null || currPage <= 0){
            this.currPage = 0;
        }else{
            this.currPage = (currPage - 1)*this.pageSize;
        }
        return this.currPage;
    }

    public void setCurrPage(Integer currPage) {
        this.currPage = currPage;
    }

    public Integer getPageSize() {
        if(pageSize == null || pageSize <= 0){
            this.pageSize = OverallConstant.DEFAULT_PAGESIZE;
        }else{
            this.pageSize = pageSize;
        }
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    @Override
    public String toString() {
        return "PageCondition{" +
                "currPage=" + currPage +
                ", pageSize=" + pageSize +
                '}';
    }
}
